Page({
  data: {
    info: {},
    swiper: [],
    linkgroup:[],
    shopgroup:[]
  },
  onLoad() {
    this.init()
  },
  init() {
    // 获取数据
    wx.request({
      url: 'https://smart-shop.itheima.net/index.php?s=/api/page/detail',
      method: "GET",
      data: {
        pageid: "0"
      },
      success: res => {
        console.log(res.data.data.pageData)
        this.setData({
          info: res.data.data.pageData,
          swiper: res.data.data.pageData.items[1].data,
          linkgroup:res.data.data.pageData.items[3].data,
          shopgroup:res.data.data.pageData.items[6].data
        })
        // this.swiper=res.data.data.pageData.items[1].data
        // console.log(this.swiper)
      }
    })
  },
  test() {
    // console.log(this.data)
    // console.log(this.swiper)
    // console.log(this.linkgroup)
    wx.navigateTo({
      url: `/pages/search/search`,
    })
  },
  itemTap:function(e){
    const id = e.currentTarget.dataset.id; // 获取 data-id 属性传递的 id
    console.log('点击的项目ID:', id);
    wx.navigateTo({
      url: `/pages/goods/goods?id=${id}`,
    })
  },
  tocategory(){
    wx.switchTab({
      url: `/pages/category/category`,
    })
  }
})